#!/usr/bin/env python
#coding=utf-8

import psutil, datetime
from subprocess import PIPE

mem = psutil.virtual_memory()
print mem
print mem.total
print mem.used

cpu_info = psutil.cpu_times()

print cpu_info
print cpu_info.user

cpu_count = psutil.cpu_count()
print cpu_count


disk_info = psutil.disk_partitions()
print disk_info
disk_usage = psutil.disk_usage("/")
print disk_usage
disk_io_counters = psutil.disk_io_counters()
print disk_io_counters


net_io_counter = psutil.net_io_counters()
print net_io_counter

users = psutil.users()
print users

uptime = datetime.datetime.fromtimestamp(psutil.boot_time()).strftime("%Y-%m-%d %H:%M:%S")
print uptime

all_pids = psutil.pids()
print all_pids

p = psutil.Process(all_pids[334])
p2 = psutil.Process(2)
p4 = psutil.Process(4)
print p.name()
print p2.name()
print p4.name()
print p.exe()
print p.cwd()
print p.status()
print p.create_time()
print p.uids()
print p.cpu_times()
print p.cpu_affinity()
print p.memory_percent()
print p.memory_info()
print p.io_counters()
print p.connections()
print p.num_threads()


pp = psutil.Popen(["/usr/bin/python", "-c", "print('hello')"], stdout=PIPE)
print pp.name()
print pp.username()
# print pp.communicate()
print pp.cpu_times()
